﻿@model IEnumerable<WebSoftSeo.Models.Consult>
@using WebSoftSeo.Models
@{
    WebSoftSeoEntities db = new WebSoftSeoEntities();
    List<Consult> consult = db.Consults.Where(m => m.ParentID == null && m.Status == true).OrderByDescending(c => c.ID).ToList();
    var list = db.Consults.ToList();
    int counts = db.Consults.Where(m => m.ParentID == null && m.Status == true).OrderByDescending(c => c.ID).ToList().Count();
    var count1 = db.Consults.Where(m => m.ParentID == null && m.Status == true).OrderByDescending(c => c.ID).Take(10);
    
    int count = counts / 10;
    int page = 0;
    for(int i =0; i<= count; i++)
    {
        page = i;
    }
}
@if (consult != null)
{
    foreach (var item in consult)
    {
    <div class="testCons">
        <p class="dateCons">@string.Format("{0:dd/MM/yyy HH:mm:ss tt}", item.Date) --- @item.Title</p>
        <p class="titleCons">@item.Contents</p>
        @{
        var listlevel2 = list.Where(m => m.ParentID == item.ID).OrderByDescending(c => c.ID).ToList();
        }
        @foreach (var lv2 in listlevel2)
        {
            <p class="replyCons">Trả lời: @lv2.Contents</p>
        }
    </div>
    }
}
@{
    int pagenew = 0;
}

<div class="clearfix"></div>
<div class="prev-next">
    <ul>
        @*<li><a href="@Url.Content("~/Consult/Index/?page=" + ((pagenew - 1) < 1 ? pagenew : (pagenew - 1)))">
            <p>Previous</p>
        </a></li>*@
        @for (int i = 1; i <= count; i++)
        {
            if (Request["page"] != null && Convert.ToInt32(Request["Page"]) == i)
            {
                <li><a class="active" href="@Url.Content("~/Consult/Index/?page=" + i)">@i</a></li>
            }
            else
            {
                <li><a href="@Url.Content("~/News/Index/?page=" + i)">@i</a></li>
            }
        }


        @*<li><a href="@Url.Content("~/News/Index/?page=" + ((pagenew + 1) > count ? pagenew : (pagenew + 1)))">Next</a></li>
    </ul>*@
    <div class="clearfix"></div>
</div>
